#include"cssignum.hpp"

void *Producer(void* arg){
    Ringqueue<int>* rq = (Ringqueue<int>*)arg;
    while(1){
        int data = rand() % 100 + 1;
        rq->Push(data);
        std::cout<<"producer:"<<data<<std::endl;
    }
}
void *Consumer(void* arg){
    Ringqueue<int>* rq = (Ringqueue<int>*)arg;
    while(1){
        sleep(1);
        int data = 0;
        rq->Pop(data);
        std::cout<<"consumer:"<<data<<std::endl;
    }
}

int main(){
    srand((unsigned int)time(nullptr));
    pthread_t producer,consumer;
    //
    Ringqueue<int>* rq = new Ringqueue<int>;
    //创建线程
    pthread_create(&producer,nullptr,Producer,rq);
    pthread_create(&consumer,nullptr,Consumer,rq);

    pthread_join(producer,nullptr);
    pthread_join(consumer,nullptr);
    delete rq;
    return 0;
}